{{ define "main" }}

{{ $pages := .Pages }}
{{ $pages = (.Paginate $pages).Pages }}

<header>
  <div class="container">
    <h1>{{ .Title }}</h1>
    <p class="subtitle">
      <span class="count">{{ len .Pages }}</span> posts found.
    </p>
  </div>
</header>

<section>
  <div class="container">
    <section>
      <section>
        <div class="posts">
          {{ range $pages }}
          <div class="post">
            <a href="{{ .RelPermalink }}">
              <div class="post-row">
                <time>{{ .Date.Format "2006-01-02" }}</time>
                <h3>{{ .Title }}</h3>
              </div>
              <!--<div class="new-post">New!</div>-->
            </a>
          </div>
          {{ end }}
        </div>
      </section>
    </section>
  </div>
</section>

{{- $scope := .Site }}
{{- $paginator := .Paginate (where $scope.RegularPages ".Params.type" "!=" "page") }}

{{- if gt $paginator.TotalPages 1}}
<section>
  <div class="container">
    <nav class="pagination">
      {{- if $paginator.HasPrev}}
      <div class="prev-page">
        <a href="{{ $paginator.Prev.URL }}">Previous Page</a>
      </div>
      {{ end }}
      {{- if $paginator.HasNext}}
      <div class="next-page">
        <a href="{{ $paginator.Next.URL }}">Next Page</a>
      </div>
      {{ end }}
    </nav>
  </div>
</section>
{{ end }}

{{ end }}
